
#ifndef HTTP_CONNECTION_H
#define HTTP_CONNECTION_H

class HttpConnection
{
private:
	int m_nResCode;
	int m_nResSize;
	char * m_lpResData;

	const int process();
	void clearData();
	void cleanup();

#ifdef USE_LIBCURL
	void * m_objCurl;
	FILE *m_tmpHeader, *m_tmpBody;

	char * m_strProxyHost;
	char * m_strProxyUser;
	char * m_strProxyPass;
	int m_nProxyPort;
#endif // USE_LIBCURL

public:
	HttpConnection();
	~HttpConnection();

#ifdef USE_LIBCURL
	// set proxy information
	void setProxy(const char *ip, const int & port, const char * user, const char * pass);

	// prepare for request
	const int prepare(const int bAutoRedirect, const int bIgnoreSecurityCheck);
#endif // USE_LIBCURL

	// request an URL
	const int requestGet(const char * url, const int bAutoRedirect = 1, const int bIgnoreSecurityCheck = 1);

	// request a form
	const int requestPost(const char *url, const char **fields, const char **values, const int bAutoRedirect = 1, const int bIgnoreSecurityCheck = 1);

	// response data
	const char * response();

	// response data size
	const int responseSize();

	// response code
	const int responseCode();
};

#endif // HTTP_CONNECTION_H
